<?php
class ORMPackagePurchase extends ORMBase {
  public function __construct() {
    parent::__construct('PackagePurchase');
  }

  public function __toEpObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMProduct.class.php';
    $epObject->trackId = isset($object->trackId) ? $object->trackId : '';
    if (isset($object->product) && $object->product) {
        $epObject->product = $this->__getEpObject_4_lvl_1_object($myManager, $object->product, new ORMProduct(), 'Product');
    } else {
      if (isset($epObject->product)) {
        $my_manager->delete($epObject->product);
      }
    }
    $epObject->quantity = isset($object->quantity) ? $object->quantity : 0;
    $epObject->price = isset($object->price) ? $object->price : 0;
    return $epObject;
  }

  public function __toObject($myManager, $epObject, $object) {
    require_once dirname(__FILE__) . '/ORMProduct.class.php';
    $object->id = $epObject->oid;
    $object->trackId = $epObject->trackId;
    if (isset($epObject->product)) {
      $object->product = $this->__getObject_4_lvl_1_ep_object($myManager, $epObject->product, new ORMProduct());
    }
    $object->quantity = $epObject->quantity;
    $object->price = $epObject->price;
    return $object;
  }
}
?>
